<?php

namespace App\Console\Commands\Cruise;

use App\Enums\OpenShop\InvestmentPromotion\SignOrderEnum;
use App\Library\Rms\RmsShopApi;
use App\Models\Cruise\CruiseCheckAgainstModel;
use App\Models\Cruise\CruiseShopAccountModel;
use App\Models\OpenShop\InvestmentPromotion\OpenShopMainProcessModel;
use App\Models\OpenShop\InvestmentPromotion\OpenShopSignOrderModel;
use App\Models\OpenShop\SiteLocation\OpenShopSiteLocationModel;
use App\Remote\Orm\OrmNewOrderRemote;
use Illuminate\Console\Command;

class UpdateCheckAgainstStartTime extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'cruise:update-check-against-startTime';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '更新违约函实际产生时间';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        CruiseCheckAgainstModel::query()
            ->where('startTime', 0)
            ->chunk(500, function ($item) {
                foreach ($item as $v) {
                    CruiseCheckAgainstModel::query()->where('id', $v->id)->update(['startTime' => strtotime($v->createdAt)]);
                }
            });
    }
}
